import {RequestRs} from '../../modules/Request-rs';
import {ReponseRs} from '../../modules/Response-rs';
import {Product} from '../../modules/product';
import {SCItem} from '../../modules/scitem';
import {User} from '../../modules/user';
import {HttpService} from './http.service';
import {Injectable} from '@angular/core';
import {CookieService} from 'angular2-cookie/services/cookies.service';
@Injectable()
export class UserService {
  constructor(private httpService: HttpService, private cookieService: CookieService) {}
  private currentUser: User;
  get getUser(): User {
    let user = this.cookieService.getObject('currentUser');
    this.currentUser = user as User;
    return this.currentUser;
  }

  set setUser(user: User) {
    this.currentUser = user;
    this.cookieService.putObject('currentUser', this.currentUser);

  }
  cleanUser() {
    this.cookieService.remove('currentUser');
    this.currentUser = null;

  }
  isLogin(): boolean {
    let user = this.cookieService.getObject('currentUser');
    if (user !== null && typeof (user) !== 'undefined') {
      return true;
    } else {
      return false;
    }
  }
}
